﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;

namespace MTP.Core.Filters
{
    public class FilterMtpCollection : Collection<IMtpFilterBase>
    {
     
        public FilterMtpCollection Add<TFilterType>() where TFilterType : IMtpFilterBase
        {
            return Add(typeof(TFilterType));
        }

     
        public FilterMtpCollection Add(Type filterType)
        {
            if (filterType == null)
            {
                throw new ArgumentNullException("filterType");
            }

            return Add(filterType, 0);
        }

      
        public FilterMtpCollection Add<TFilterType>(int order) where TFilterType : IMtpFilterBase
        {
            return Add(typeof(TFilterType), order);
        }

        public FilterMtpCollection Add(Type filterType, int order)
        {
            if (filterType == null)
            {
                throw new ArgumentNullException("filterType");
            }
            if (!typeof(IMtpFilterBase).IsAssignableFrom(filterType))
            {
                throw new ArgumentException("filterType must be IMtpFilterBase");
            }
            Add(new MtpTypeFilter(filterType));
            return this;
        }

    }
}
